*This file creates Table 5

use "$output/regloop10end.dta", clear
local j = 1
global internal "age female urban nevermarried hadsex sexage sexagesq primary secondary matric tertiary condom_first know1 know2 know3 know4 malepension fempension"

matrix input balanceb = ()
matrix input balancese = ()
matrix input balancet = ()
matrix input balancen = ()
foreach var of global internal   {
      qui reg `var' positive [pw=weight] if subgroup`j'==1
      matrix balanceb = balanceb \ _b[positive]
      matrix balancese = balancese \ _se[positive]
      matrix balancet = balancet \ (_b[positive]/_se[positive])
}
matrix input internala`j'=()
matrix internala`j' = balanceb, balancese, balancet 

matrix input balanceb = ()
matrix input balancese = ()
matrix input balancet = ()
matrix input balancen = ()
foreach var of global internal  {
      qui reg `var' positive [pw=pscoreweight] if subgroup`j'==1
      matrix balanceb = balanceb \ _b[positive]
      matrix balancese = balancese \ _se[positive]
      matrix balancet = balancet \ (_b[positive]/_se[positive])
}
matrix input internalb`j'=()
matrix internalb`j' = balanceb, balancese, balancet
*Create Table 5
matrix internal`j'=internala`j', internalb`j'
matrix list internal`j'

exit
